package com.tianji.aigc.controller;


import com.tianji.aigc.dto.ChatDTO;
import com.tianji.aigc.enums.ChatEventTypeEnum;
import com.tianji.aigc.service.ChatService;
import com.tianji.aigc.vo.ChatEventVO;
import com.tianji.aigc.vo.TemplateVO;
import com.tianji.common.annotations.NoWrapper;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

import javax.print.attribute.standard.Media;
import java.awt.*;

@RequestMapping("/chat")
@RestController
public class ChatController {


    @Autowired
    private ChatService chatService;

    /**
     * 聊天接口
     * @param chatDTO
     * @return
     */
    @PostMapping(produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    @NoWrapper
    public Flux<ChatEventVO> chat(@RequestBody ChatDTO chatDTO) {
        return  chatService.chat(chatDTO);
    }


    /**
     * 停止生成
     */
    @PostMapping("/stop")
    public void stop(@RequestParam("sessionId") String sessionId) {
        chatService.stop(sessionId);
    }


    /**
     * 文本聊天功能
     */
    @PostMapping("/text")
    public String TextChat(@RequestBody String question){
        return chatService.TextChat(question);

    }

    private static final TemplateVO TEMPLATE_VO = new TemplateVO();

    @GetMapping("/templates")
    public TemplateVO getTemplates() {
        return TEMPLATE_VO;
    }




}
